import { reactive, ref } from 'vue'
import { reqAddAppBody } from '@/pages/member/api/types/application'
import { FormItemType } from '@/components/form/type'

export const useApplicationHook = () => {
  const formData = ref<reqAddAppBody>({
    type: 1,
    subType: 1,
    buildNo: '',
    title: '',
    titleEn: '',
    description: '',
    useLanguage: [],
    calculateNode: 1,
    images: '',
    applicationType: [],
  })
  const formItem = reactive<FormItemType[]>([
    {
      type: 'input',
      label: '子流程ID',
      prop: 'titleEn',
      required: true,
    },
    {
      type: 'input',
      label: '子流程名称',
      prop: 'title',
      required: true,
    },
    {
      type: 'input',
      label: '版本号',
      prop: 'buildNo',
      required: true,
    },
    {
      type: 'textarea',
      label: '子流程说明',
      prop: 'description',
      required: true,
    },
    {
      type: 'radioBtn',
      label: '计算节点',
      prop: 'calculateNode',
      required: true,
      options: [
        { label: 'CPU', value: 1 },
        { label: 'GPU', value: 2 },
      ],
    },
    {
      type: 'slot',
      label: '展示图片',
      slotName: 'uploadImg',
      prop: 'image',
    },
    {
      type: 'slot',
      label: '展示视频',
      slotName: 'uploadVideo',
      prop: 'video',
    },
  ])
  return {
    formData,
    formItem,
  }
}
